# -*- coding: utf-8 -*-
import os
import platform
from config import config_base_data
from configparser import ConfigParser

CUR_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))

conf = ConfigParser(os.environ)
config_path = os.path.join(CUR_DIR, 'config.ini')
conf.read(config_path)

SYSTEM_NAME = platform.system().lower()
if SYSTEM_NAME == 'windows' or SYSTEM_NAME == 'darwin':

    data_mysql_name = 'DATA_MYSQL_INNO_LOCAL'  # 第三方数据库
    redis_name = 'REDIS_INNO_LOCAL'
    container_monitor_flag = False
    SCHEDULER_FLUSH_ON_START = True
    public_env = 'local'  # 运行环境
    local_env = True
else:
    data_mysql_name = 'DATA_MYSQL_INNO_DEV'  # 第三方数据库
    redis_name = 'REDIS_INNO_DEV'
    container_monitor_flag = True
    SCHEDULER_FLUSH_ON_START = False
    public_env = 'prod'  # 运行环境
    local_env = False
# PDF_CONFIG = pdfkit.configuration(wkhtmltopdf='D:/wkhtmltopdf/bin/wkhtmltopdf.exe')

# 数据 mysql 配置
DATA_DB_HOST = conf.get(data_mysql_name, 'host')
DATA_DB_USER = conf.get(data_mysql_name, 'user')
DATA_DB_PASSWORD = conf.get(data_mysql_name, 'password')
DATA_DB_NAME = conf.get(data_mysql_name, 'dbname')
DATA_DB_CHARSET = conf.get(data_mysql_name, 'charset')
DATA_DB_PORT = int(conf.get(data_mysql_name, 'port'))

# Redis 配置
REDIS_HOST = conf.get(redis_name, 'host')
REDIS_PORT = conf.getint(redis_name, 'port')
REDIS_PASSWORD = conf.get(redis_name, 'password')
REDIS_ENCODING = conf.get(redis_name, 'encoding')
REDIS_DB = conf.getint(redis_name, 'db')
PUBLIC_ENV = public_env
# 这个路径需要后期优化
# node路径
NODE_PATH = '/usr/local/lib/node_modules'
# 实时代理
REALTIME_PROXY_LIST = config_base_data['base']['proxy']['victor']['REALTIME_PROXY']
ABROAD_PROXY_LIST = config_base_data['base']['proxy']['victor']['ABROAD_PROXY']
LOG_LEVEL = config_base_data['base']['scrapy']['LOG_LEVEL']
LOG_FILE = config_base_data['base']['scrapy']['LOG_FILE']
MONITOR_LOG_FILE = config_base_data['base']['log']['MONITOR_LOG_FILE']
LINK_LOG_FILE = config_base_data['base']['log']['LINK_LOG_FILE']
